<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0,minimum-scale=1.0,maximum-scale=1.0" />
    <meta name="apple-touch-fullscreen" content="yes" />
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <meta name="apple-mobile-web-app-status-bar-style" content="black" />
    <meta name="format-detection" content="telephone=no" />
    <meta name="x5-fullscreen" content="true" />
    <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1" />

    <!-- 标题及搜索关键字 -->
    <meta name="keywords" content="火星科技,cesium,3D,GIS,marsgis,三维,地球,地图,开发,框架,系统,示例,资料,模型,离线,外包,合肥,安徽,中国" />
    <meta
      name="description"
      content="火星科技 合肥火星 合肥火星科技 合肥火星科技有限公司 leaflet leaflet框架 leaflet开发 cesium cesium开发 cesium框架 三维 地球 模型  gis marsgis 地图离线 地图开发 地图框架 地图外包 框架 开发 外包  地图离线 二维地图 三维地图 全景漫游 地理信息系统 云GIS 三维GIS GIS平台 WebGIS"
    />

    <link rel="shortcut icon" type="image/x-icon" href="http://mars3d.cn/favicon.ico" />
    <title>点对象动态位置 | Mars3D | 三维地图 | 火星科技 | 合肥火星科技有限公司</title>

    <script
      type="text/javascript"
      src="../lib/include-lib.js"
      libpath="../lib/"
      include="jquery,font-awesome,bootstrap,bootstrap-checkbox,layer,haoutil,turf,mars3d"
    ></script>

    <link href="css/style.css" rel="stylesheet" />
  </head>

  <body class="dark">
    <!--加载前进行操作提示，优化用户体验-->
    <div id="mask" class="signmask" onclick="removeMask()"></div>

    <div id="mars3dContainer" class="mars3d-container"></div>

    <div class="infoview">
      图层状态：
      <div class="checkbox checkbox-primary checkbox-inline">
        <input id="chkShow" class="styled" type="checkbox" checked />
        <label for="chkShow"> 显示隐藏 </label>
      </div>
      <div class="checkbox checkbox-primary checkbox-inline">
        <input id="chkPopup" class="styled" type="checkbox" checked />
        <label for="chkPopup"> Popup绑定 </label>
      </div>
      <div class="checkbox checkbox-primary checkbox-inline">
        <input id="chkTooltip" class="styled" type="checkbox" />
        <label for="chkTooltip"> Tooltip绑定 </label>
      </div>
      <div class="checkbox checkbox-primary checkbox-inline">
        <input id="chkContextMenu" class="styled" type="checkbox" checked />
        <label for="chkContextMenu"> 右键菜单绑定 </label>
      </div>

      &nbsp;&nbsp; &nbsp;&nbsp;

      <a href="editor.html#f10_entity_dynamic_3dtiles" target="_blank" class="btn btn-default">动态贴模型示例</a>
    </div>

    <!-- 切换视角到模型或地形（山区）的快捷按钮 -->
    <script type="text/javascript" src="js/center_terrain_3dtiles.js"></script>

    <!-- 图层管理相关处理js -->
    <script type="text/javascript" src="./js/graphicManager.js"></script>

    <script src="./js/common.js"></script>
    <script type="text/javascript">
      "use script"; //开发环境建议开启严格模式

      var map;

      function initMap(options) {
        //合并属性参数，可覆盖config.json中的对应配置
        var mapOptions = mars3d.Util.merge(options, {
          scene: {
            fxaa: true,
            center: { lat: 31.754913, lng: 117.248572, alt: 6220, heading: 357, pitch: -31 },
          },
        });

        //创建三维地球场景
        map = new mars3d.Map("mars3dContainer", mapOptions);

        map.basemap = 2017; //蓝色底图

        //固定光照，避免gltf模型随时间存在亮度不一致。
        map.fixedLight = true;

        //创建矢量数据图层
        var graphicLayer = new mars3d.layer.GraphicLayer();
        map.addLayer(graphicLayer);

        //图层管理的相关处理，代码在\js\graphicManager.js
        initLayerManager(graphicLayer);

        //加一些演示数据
        for (let i = 0; i < 20; i++) {
          let graphic = new mars3d.graphic.ModelEntity({
            style: {
              url: "//data.mars3d.cn/gltf/mars/qiche.gltf",
              scale: 0.5,
              minimumPixelSize: 20,

              //高亮时的样式（默认为鼠标移入，也可以指定type:'click'单击高亮），构造后也可以openHighlight、closeHighlight方法来手动调用
              highlight: {
                type: mars3d.EventType.click,
                silhouette: true,
                silhouetteColor: "#ff0000",
                silhouetteSize: 4,
              },

              label: {
                //不需要文字时，去掉label配置即可
                text: "皖A000" + i,
                font_size: 16,
                color: "#ffffff",
                outline: true,
                outlineColor: "#000000",
                pixelOffsetY: -20,
                distanceDisplayCondition: true,
                distanceDisplayCondition_far: 50000,
                distanceDisplayCondition_near: 0,
              },
            },
          });
          graphicLayer.addGraphic(graphic);
        }
        for (let i = 0; i < 20; i++) {
          let graphic = new mars3d.graphic.BillboardEntity({
            style: {
              image: "img/marker/mark3.png",
              scale: 0.6,
              horizontalOrigin: Cesium.HorizontalOrigin.CENTER,
              verticalOrigin: Cesium.VerticalOrigin.BOTTOM,
              scaleByDistance: new Cesium.NearFarScalar(10000, 1.0, 500000, 0.1),
            },
          });
          graphicLayer.addGraphic(graphic);
        }
        for (let i = 0; i < 3; i++) {
          let graphic = new mars3d.graphic.DivUpLabel({
            style: {
              text: "火星科技",
              color: "#fff",
              font_size: 13,
              font_family: "微软雅黑",
              lineHeight: 20,
              circleSize: 5,
              distanceDisplayCondition: new Cesium.DistanceDisplayCondition(0, 100000),
            },
          });
          graphicLayer.addGraphic(graphic);
        }

        //设置动态位置
        graphicLayer.eachGraphic((graphic) => {
          graphic.addDynamicPosition(randomPoint());
        });
        graphicLayer.eachGraphic((graphic) => {
          graphic.addDynamicPosition(randomPoint(), 20);
        });

        //定时更新动态位置（setInterval为演示）
        setInterval(() => {
          graphicLayer.eachGraphic((graphic) => {
            graphic.addDynamicPosition(randomPoint(), 20);
          });
        }, 20000);
      }

      //取区域内的随机图标
      function randomPoint() {
        var jd = haoutil.math.random(117.207666 * 1000, 117.287241 * 1000) / 1000;
        var wd = haoutil.math.random(31.817099 * 1000, 31.876848 * 1000) / 1000;
        return Cesium.Cartesian3.fromDegrees(jd, wd, 30);
      }
    </script>
  </body>
</html>
